﻿var maxpage = 0;
var currPageIndex = 0;
var maxcount = 0;
$(document).ready(function () {
    $("#btn_Start_Pay").click(function () {
        var money = $("#Pay_Money").val();
        if (money == "") {
            alert("请输入金额");
            return false;
        }
        if (isNaN(money)) {
            alert("请输入正确金额");
            return false;
        }
        window.open("RequestHandler.ashx?action=paymoney&ut=custom&pm=" + money +"&st="+Math.random());
    });
});
function gopage(pageIndex) {
    if (pageIndex == "")
        return;
    if (pageIndex < 1)
        return;
}
function InitData(pageIndex) {
    var url = "RequestHandler.ashx?v=1.0&action=ptif&ut=custom&tagmode=any&format=json&jsoncallback=?&pageIndex=" + pageIndex + "&st=" + Math.random();
    //$.getJSON(url, function (data) {
    $.get(url, function (data) {
        var json = (new Function('return ' + data))();
        maxpage = json.maxpage;
        currPageIndex = json.pageIndex;
        maxcount = json.maxcount;
        var result = "";
        $.each(json.items, function (i, item) {
            if (item != null) {
                result += "<tr>";
                result += "<td align=\"center\" class=\"tddetailleft\">" + item.Commit_Date + "</td>";
                result += "<td class=\"tddetail\">" + item.Total_fee + "</td>";
                result += "<td class=\"tddetail\">" + item.Rechargepoints + "</td>";
                result += "<td class=\"tddetail\">" + item.GiftPoints + "</td>";
                result += "<td class=\"tddetail\">" + item.RewardPoints + "</td>";
                //result += "<td class=\"tddetailright\">" + (item.Rechargepoints + item.RewardPoints + item.Rechargepoints) + "</td>";
                result += "<td class=\"tddetailright\">" + item.Balance + "</td>";
                result += "</tr>";
            }
        });
        $("#TBody_Template").html(result);
        $("#Span_Page_Count").text(maxpage);
    });
}

function gopage(pageIndex) {
    if (pageIndex == "")
        return;
    if (pageIndex > maxpage)
        return;
    if (pageIndex < 1)
        return;
    InitData(pageIndex);
}

$(document).ready(function () {
    InitData(1);
    var url = "RequestHandler.ashx?v=1.0&action=qu&ut=pcdata";
    $.get(url, function (data) {
        var json = (new Function('return ' + data))();
        var result = "";
        $.each(json.items, function (i, item) {
            if (item != null) {
                if (i == 0) {
                    result += "<tr>";
                    result += "<td style=\"width:20%;height:10px;padding-left:20px;padding-top:2px;\">*</td>";
                    result += "<td style=\"width:50%;\">一次性充" + item.OneTimeMoney + "元</td>";
                    result += "<td style=\"width:30%;\">送" + item.PresentBalancePoint + "积分</td>";
                    result += "</tr>";
                } else {
                    result += "<tr>";
                    result += "<td style=\"height:18px;padding-left:20px;padding-top:2px;\">*</td>";
                    result += "<td>一次性充" + item.OneTimeMoney + "元</td>";
                    result += "<td>送" + item.PresentBalancePoint + "积分</td>";
                    result += "</tr>";
                }
            }
        });
        result += "<tr>";
        result += "<td colspan=\"3\" style=\"text-align:center;height:30px;padding-left:20px;\">&nbsp;</td>";
        result += "</tr>";
        result += "<tr>";
        result += "<td style=\"height:100%;\"></td>";
        result += "<td></td>";
        result += "<td></td>";
        result += "</tr>";
        if (result != "")
            $("#presentcharge").html(result);
    });
});